package com.bnlr.lrparking.appui.mine.mygnd;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bnlr.lrparking.R;
import com.bnlr.lrparking.appui.mine.mygnd.GndLockBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * package: com.bnlr.lrparking.appui.mine.adapter
 * filename: GndLockAdapter
 * author: Licy
 * date: 2018/11/21
 * description: TODO
 */
public class GndLockAdapter extends BaseQuickAdapter<GndLockBean.DataBean, BaseViewHolder> {

    public interface OnItemClickListener {
        void onItemClick(int position);
    }

    public GndLockAdapter(int layoutResId, @Nullable List<GndLockBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        return super.onCreateViewHolder(parent, viewType);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, GndLockBean.DataBean dataBean) {
        ImageView img = baseViewHolder.getView(R.id.item_gnd_img);
        Glide.with(mContext).load(dataBean.getParkPhoto())
                .placeholder(R.mipmap.tab2_defaultgraph)
                .error(R.mipmap.tab2_defaultgraph)
                .into(img);

        baseViewHolder.setText(R.id.gnd_parking_title, dataBean.getName());
        baseViewHolder.setText(R.id.gnd_parking_address, dataBean.getAddress());
//        baseViewHolder.setText(R.id.gnd_parking_number, dataBean.getParkingId());
        baseViewHolder.setText(R.id.gnd_parking_status, dataBean.getStatus());

        TextView status = baseViewHolder.getView(R.id.gnd_parking_status);
        TextView gnd_open = baseViewHolder.getView(R.id.gnd_open);
        TextView gnd_close = baseViewHolder.getView(R.id.gnd_close);

        baseViewHolder.addOnClickListener(R.id.gnd_open)
                .addOnClickListener(R.id.gnd_close);


        if (TextUtils.equals("已关闭", dataBean.getStatus())) {
            // 设置 状态
            status.setTextColor(mContext.getResources().getColor(R.color.stroke_EA5544));
            // 设置 打开地锁 样式
            gnd_open.setClickable(true);
            gnd_open.setTextColor(mContext.getResources().getColor(R.color.stroke_00CAA3));
            gnd_open.setBackground(mContext.getResources().getDrawable(R.drawable.bg_tv_shape_open));
            // 设置 关闭地锁 样式
            gnd_close.setClickable(false);
            gnd_close.setTextColor(mContext.getResources().getColor(R.color.stroke_BBBBBB));
            gnd_close.setBackground(mContext.getResources().getDrawable(R.drawable.bg_tv_shape_normal));

        } else {
            // 设置 状态
            status.setTextColor(mContext.getResources().getColor(R.color.stroke_00CAA3));
            // 设置 打开地锁 样式
            gnd_open.setClickable(false);
            gnd_open.setTextColor(mContext.getResources().getColor(R.color.stroke_BBBBBB));
            gnd_open.setBackground(mContext.getResources().getDrawable(R.drawable.bg_tv_shape_normal));
            // 设置 关闭地锁 样式
            gnd_close.setClickable(true);
            gnd_close.setTextColor(mContext.getResources().getColor(R.color.stroke_EA5544));
            gnd_close.setBackground(mContext.getResources().getDrawable(R.drawable.bg_tv_shape_close));
        }


    }

}
